<style lang="less">
@import '../../../styles/common.less';
</style>

<template>
    <Card>
        <Card>
            <div style="margin-left: 42%;">
                <div style="margin-top:30px">
                    <div style="float:left;width:140px">确认日期：</div>
                    <div>
                        <DatePicker v-model="transferCondition.confirmDate" type="date" style="width: 150px"></DatePicker>
                    </div>
                </div>
                <div style="margin-top:30px">
                    <div style="float:left;width:140px">项目名称：</div>
                    <div>
                        <Select v-model="transferCondition.projectCode" class="v-select-wrapper" style="width:150px" :label-in-value=true @on-change="projectChange">
                            <Option v-for="item in projectNameList" :value="item.key" :key="item.key">{{ item.label }}</Option>
                        </Select>
                    </div>
                </div>
                <div style="margin-top:30px">
                    <div style="float:left;width:140px">批次号：</div>
                    <div>
                        <Input v-model="transferCondition.batchNo" style="width: 150px" />
                    </div>
                </div>
                <div style="margin-top:30px">
                    <div style="float:left;width:140px">回款日期：</div>
                    <div style="float:left">
                        <DatePicker v-model="transferCondition.backStartDate" type="date" style="width: 150px"></DatePicker>
                    </div>
                    <div style="float:left;margin-left: 10px;">
                        至
                    </div>
                    <div style="float:left;margin-left: 10px;">
                        <DatePicker v-model="transferCondition.backEndDate" type="date" style="width: 150px"></DatePicker>
                    </div>
                    <Button type="primary" style="margin-top:-4px;margin-left:50px;" @click="calculate">计算</Button>
                </div>
            </div>
            <div style="text-align:center;margin-top: 40px;">
                <Table border :columns="orderColumns1" :data="orderData1" style="width: 100%;"></Table>
            </div>
            <div style="text-align:center;margin-top: 40px;">
                <Table border :columns="orderColumns2" :data="orderData2" style="width: 100%;"></Table>
            </div>
            <div style="text-align:center;margin-top: 40px;">
                <Table border :columns="orderColumns3" :data="orderData3" style="width: 100%;"></Table>
            </div>
            <div style="margin-top: 40px;text-align:center">
                <Button type="primary" @click="determineAdd">确定新增</Button>
            </div>
        </Card>
    </Card>
</template>

<script>
export default {
  name: 'mutative-router',
  data () {
    return {
      transferCondition: {
        confirmDate: '', // 确认日期
        projectCode: '', // 项目名称
        batchNo: '', // 批次号
        backStartDate: '', // 回款日期(起)
        backEndDate: '', // 回款日期(止)
        specialAccountSumMoney: '', // 专户资金流入总额
        specialAccountPrincipal: '', // 本金
        specialAccountInterest: '', // 利息
        specialAccountPenalty: '', // 罚息
        differenceReason: '', // 差异原因
        differenceSumMoney: '', // 差异金额
        trustMoney: '', // 信托资金
        bankInterest: '', // 银行利息
        stepCharge: '', // 暂收款
        otherCharge: '', // 其他暂收款
        otherPrincipal: '', // 冲其他暂收款(本金)
        otherInterest: '', // 冲其他暂收款(利息)
        otherFee: '', // 三方费用
        otherPenalty: '', // 冲其他暂收款(罚息)
        otherStepCharge: '', // 冲其他暂收款(暂收款)

        paymentSumMoney: '', // 还款明细表 总额
        paymentPrincipal: '', // 还款明细表     本金
        paymentInterest: '', // 还款明细表    利息
        paymentPenalty: '', // 还款明细表       罚息
        serviceSumMoney: '', // 趸交服务费 总额
        servicePrincipal: '', // 趸交服务费     本金
        serviceInterest: '', // 趸交服务费    利息
        servicePenalty: '', // 趸交服务费       罚息
        details: [
          {
            rise: '',
            totalAmount: '',
            principal: '',
            interest: '',
            fine: ''
          },
          {
            rise: '',
            totalAmount: '',
            principal: '',
            interest: '',
            fine: ''
          }
        ]
      },
      projectNameList: [
        {
          key: 'YKD01',
          label: '云科谷个人消费贷款单一资金信托项目'
        }
      ],
      orderColumns1: [
        {
          title: '项目',
          align: 'center',
          key: 'projectName'
        },
        {
          title: '专户资金流入总额',
          align: 'center',
          key: 'specialAccountSumMoney',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.specialAccountSumMoney
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'specialAccountSumMoney', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '本金',
          align: 'center',
          key: 'specialAccountPrincipal',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.specialAccountPrincipal
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'specialAccountPrincipal', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '利息',
          align: 'center',
          key: 'specialAccountInterest',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.specialAccountInterest
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'specialAccountInterest', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '罚息',
          align: 'center',
          key: 'specialAccountPenalty',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.specialAccountPenalty
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'specialAccountPenalty', e.target.value)
                }
              }
            })
          }.bind(this)
        }
      ],
      orderData1: [
        {
          projectName: '信托专户',
          specialAccountSumMoney: '',
          specialAccountPrincipal: '',
          specialAccountInterest: '',
          specialAccountPenalty: ''
        }
      ],
      orderColumns2: [
        {
          title: '',
          key: 'rise'
        },
        {
          title: '总额',
          align: 'center',
          key: 'totalAmount',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.details[params.row.index].totalAmount
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition.details[params.row.index], 'totalAmount', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '本金',
          align: 'center',
          key: 'principal',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.details[params.row.index].principal

              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition.details[params.row.index], 'principal', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '利息',
          align: 'center',
          key: 'interest',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.details[params.row.index].interest
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition.details[params.row.index], 'interest', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '罚息',
          align: 'center',
          key: 'fine',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.details[params.row.index].fine
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition.details[params.row.index], 'fine', e.target.value)
                }
              }
            })
          }.bind(this)
        }
      ],
      orderData2: [
        {
          index: '0',
          rise: '还款明细表',
          totalAmount: '',
          principal: '',
          interest: '',
          fine: ''
        },
        {
          index: '1',
          rise: '趸交服务费',
          totalAmount: '',
          principal: '',
          interest: '',
          fine: ''
        }

      ],
      orderColumns3: [
        {
          title: '差异原因',
          align: 'center',
          key: 'differenceReason',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.differenceReason
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'differenceReason', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '差异金额',
          align: 'center',
          key: 'differenceSumMoney',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.differenceSumMoney
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'differenceSumMoney', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '信托资金',
          align: 'center',
          key: 'trustMoney',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.trustMoney
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'trustMoney', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '银行利息',
          align: 'center',
          key: 'bankInterest',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.bankInterest
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'bankInterest', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '暂收款',
          align: 'center',
          key: 'stepCharge',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.stepCharge
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'stepCharge', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '其他暂收款',
          align: 'center',
          key: 'otherCharge',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherCharge
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherCharge', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '冲其他暂收款(本金)',
          align: 'center',
          key: 'otherPrincipal',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherPrincipal
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherPrincipal', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '冲其他暂收款(利息)',
          align: 'center',
          key: 'otherInterest',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherInterest
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherInterest', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '三方费用',
          align: 'center',
          key: 'otherFee',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherFee
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherFee', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '冲其他暂收款(罚息)',
          align: 'center',
          key: 'otherPenalty',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherPenalty
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherPenalty', e.target.value)
                }
              }
            })
          }.bind(this)
        },
        {
          title: '冲其他暂收款(暂收款)',
          align: 'center',
          key: 'otherStepCharge',
          render: function (h, params) {
            const vm = this
            return h('Input', {
              props: {
                type: 'text',
                value: vm.transferCondition.otherStepCharge
              },
              on: {
                'on-change' (e) {
                  vm.$set(vm.transferCondition, 'otherStepCharge', e.target.value)
                }
              }
            })
          }.bind(this)
        }
      ],
      orderData3: [
        {
          differenceReason: '',
          differenceSumMoney: '',
          trustMoney: '',
          bankInterest: '',
          stepCharge: '',
          otherCharge: '',
          otherPrincipal: '',
          otherInterest: '',
          otherFee: '',
          otherPenalty: '',
          otherStepCharge: ''
        }
      ]
    }
  },
  computed: {
    avatorImage () {
      return localStorage.avatorImgPath
    }
  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
  },

  methods: {
    determineAdd () {
      var vm = this
      vm.transferCondition.paymentSumMoney = vm.transferCondition.details[0].totalAmount
      vm.transferCondition.paymentPrincipal = vm.transferCondition.details[0].principal
      vm.transferCondition.paymentInterest = vm.transferCondition.details[0].interest
      vm.transferCondition.paymentPenalty = vm.transferCondition.details[0].fine
      vm.transferCondition.serviceSumMoney = vm.transferCondition.details[1].totalAmount
      vm.transferCondition.servicePrincipal = vm.transferCondition.details[1].principal
      vm.transferCondition.serviceInterest = vm.transferCondition.details[1].interest
      vm.transferCondition.servicePenalty = vm.transferCondition.details[1].fine
      this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/fund/bhLiquidation/service/addConfirmPayment', vm.transferCondition).then(re => {
        var data = re.data
        var message = data.message
        this.$Message.warning(message)
        vm.goBack()
      }).catch(er => {

      })
    },
    goBack () {
      this.$router.push({ name: 'repayment-confirm' })// 类似post传参
    },
    calculate () {
      var vm = this
      this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/fund/bhLiquidation/service/calculateConfirmPayment', vm.transferCondition).then(re => {
        var data = re.data
        vm.transferCondition.details[0].principal = data.data.principalAct
        vm.transferCondition.details[0].interest = data.data.interest
        vm.transferCondition.details[0].fine = data.data.fineAct
        vm.transferCondition.details[0].totalAmount = data.data.fineAct
      }).catch(er => {

      })
    },
    projectChange (value) {
      var vm = this
      vm.transferCondition.projectName = value.label
    }
  }

}
</script>
<style>
</style>
